package com.jiangnan.warehouse_management.mapper;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jiangnan.warehouse_management.dto.request.RegisterRequest;
import com.jiangnan.warehouse_management.dto.response.RegisterResponse;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.jiangnan.warehouse_management.pojo.User;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    
    @Select("SELECT * FROM users WHERE username = #{username}")
    User findByUsername(String username);

    @Insert("INSERT INTO users (username, password, real_name, phone, email, role, status, created_at, updated_at) " +
            "VALUES (#{username}, #{password}, #{realName}, #{phone}, #{email}, #{role}, #{status}, NOW(), NOW())")
    void register(RegisterRequest request);

    @Update("UPDATE users SET password = #{newPwd} WHERE user_id = #{id}")
    void updatePwd(int id, String newPwd);
}